﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using SmartSpace.WpfShell.ServiceRef;

namespace SmartSpace.WpfShell.Modules.Dynamic.Windows
{
    /// <summary>
    /// Interaction logic for SelectToObjectWindow.xaml
    /// </summary>
    public partial class SelectToObjectWindow : Window
    {
        public User SelectedUser { get; set; }

        public SelectToObjectWindow()
        {
            InitializeComponent();
        }

        public SelectToObjectWindow(IEnumerable<User> users)
        {
            InitializeComponent();

            ListCollectionView GroupedCustomers = new ListCollectionView(new List<User>(users)); 
            GroupedCustomers.GroupDescriptions.Add(new PropertyGroupDescription("RoleCaption"));
            _ctlGridUser.ItemsSource = GroupedCustomers;
        }

        private void _ctlBtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            SelectedUser = _ctlGridUser.SelectedItem as User;
            if (SelectedUser != null)
            {
                DialogResult = true;
            }
        }
    }
}
